<template>
  <view class="my-setter-container">
    <!-- 全选区域 -->
    <view class="radio">
      <label class="radio" @click="changeAllcheck">
        <radio :checked="isFullCheck" color="#C00000"/><text></text>
      </label>
      <text>全选</text>
    </view>
    <!-- 合计区域 -->
    <view class="amount-box">
      合计：<text class="amount">¥{{checkedGoodsAmount}}</text>
    </view>
    <!-- 结算按钮 -->
    <view class="btn-settle" @click="settleFn">
      结算({{checkAmount}})
    </view>
  </view>
</template>

<script>
  import {mapGetters, mapMutations, mapState} from 'vuex'
  export default {
    name:"my-settle",
    data() {
      return {
        
      };
    },
    computed: {
      ...mapGetters('cart', ['total', 'checkAmount', 'checkedGoodsAmount']),
      ...mapGetters('user', ['addstr']),
      ...mapState('user', ['token']),
      isFullCheck(){
        return this.total === this.checkAmount
      }
    },
    methods: {
      ...mapMutations('cart', ['updateAllGoodsState']),
      changeAllcheck(){
        this.updateAllGoodsState(!this.isFullCheck)
      },
      settleFn(){
        // 判断是否选择结算商品
        if(!this.checkAmount) return uni.$showMsg('请选择要结算的商品')
        // 判断是否选择收获地址
        if(!this.addstr) return uni.$showMsg('请选择收获地址')
        // 判断是否登录
        if(!this.token) return uni.$showMsg('请先登录')
      }
    }
  }
</script>

<style lang="scss">
.my-setter-container{
  // 底部固定定位
  position: fixed;
  left: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 5px;
  // 结算区域宽度与背景颜色
  width: 100%;
  height: 50px;
  background-color: white;
  font-size: 14px;
  // 全选按钮
  .radio{
    display: flex;
    align-items: center;
  }
  // 合计文本
  .amount{
    color: #C00000;
  }
  .btn-settle{
    height: 50px;
    min-width: 100px;
    text-align: center;
    line-height: 50px;
    color: white;
    background-color: #C00000;
    padding: 0 10px;
  }
}
</style>